/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidades;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Felipe
 */
@Entity
@Table(name = "vacas")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Vacas.findAll", query = "SELECT v FROM Vacas v"),
    @NamedQuery(name = "Vacas.findByVacasId", query = "SELECT v FROM Vacas v WHERE v.vacasId = :vacasId"),
    @NamedQuery(name = "Vacas.findByCodigo", query = "SELECT v FROM Vacas v WHERE v.codigo = :codigo")})
public class Vacas implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    //@NotNull
    @Column(name = "vacas_id")
    
    private Integer vacasId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 6)
    @Column(name = "codigo")
    private String codigo;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idVacas")
    private Collection<Consultas> consultasCollection;

    public Vacas() {
    }

    public Vacas(Integer vacasId) {
        this.vacasId = vacasId;
    }

    public Vacas(Integer vacasId, String codigo) {
        this.vacasId = vacasId;
        this.codigo = codigo;
    }

    public Integer getVacasId() {
        return vacasId;
    }

    public void setVacasId(Integer vacasId) {
        this.vacasId = vacasId;
    }

    public String getCodigo() {
        return codigo;
    }

    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }

    @XmlTransient
    public Collection<Consultas> getConsultasCollection() {
        return consultasCollection;
    }

    public void setConsultasCollection(Collection<Consultas> consultasCollection) {
        this.consultasCollection = consultasCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (vacasId != null ? vacasId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Vacas)) {
            return false;
        }
        Vacas other = (Vacas) object;
        if ((this.vacasId == null && other.vacasId != null) || (this.vacasId != null && !this.vacasId.equals(other.vacasId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.Vacas[ vacasId=" + vacasId + " ]";
    }
    
}
